package com.bykj.property.config.common.webApp;

import org.apache.catalina.connector.Connector;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.stereotype.Component;

/**
 * @author yiming
 * @title: PortalTomcatWebServerCustomizer
 * @projectName property
 * @description: TODO
 * @date 2019/8/1910:11
 */
@Component
public class PortalTomcatWebServerCustomizer  implements WebServerFactoryCustomizer {


    @Override
    public void customize(WebServerFactory factory) {
        TomcatServletWebServerFactory containerFactory = (TomcatServletWebServerFactory) factory;
        containerFactory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
            @Override
            public void customize(Connector connector) {
                connector.setAttribute("relaxedQueryChars", "[]|{}^&#x5c;&#x60;&quot;&lt;&gt;");//这里需要转义，微博上被转换了
                connector.setAttribute("relaxedPathChars", "//[//]//|");
            }
        });
    }
}
